package com.yinhe.music.yhmusic.localmusic.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.model.Music;
import com.yinhe.music.yhmusic.utils.MusicUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hasee on 2017/8/15.
 */

public class LocalFileAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private List<Music> musicList;

    public LocalFileAdapter(List<Music> musicList,@Nullable List<String> data) {
        super(R.layout.local_file_item,data);
        this.musicList = musicList;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        String folderName = item.substring(item.lastIndexOf("/") + 1);
        int songSum = MusicUtils.getFileSong(musicList,item).size();
        helper.setText(R.id.path_name, item)
                .setText(R.id.folder_name, folderName)
                .setText(R.id.song_sum,songSum+"首");
    }
}
